bitkeeper revision 1.1071.1.3 (40f3f494hMH1GKUQuCB0vUKhJyfyoA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 13 Jul 2004 14:41:24 +0000 (14:41 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 13 Jul 2004 14:41:24 +0000 (14:41 +0000)
Add a conswitch command-line option to Xen.

README.CD
docs/HOWTOs/Xen-HOWTO
xen/common/kernel.c
xen/drivers/char/console.c

index c74f48beac0680136e5c7a877eb986bd3a5f4e2a..be17acfc54372e5c986b022f0a4742bf2f660425 100644 (file)
--- a/README.CD
+++ b/README.CD
@@ -307,6 +307,16 @@ that may be able to help diagnose problems:
                   transmitted/received character.
  [NB. Default for this option is 'com1,tty']
 
+ conswitch=<switch-char><auto-switch-char>
+                  Specify how to switch serial-console input between
+                  Xen and DOM0. The required sequence is CTRL-<switch_char>
+                  pressed three times. Specifying '`' disables switching.
+                  The <auto-switch-char> specifies whether Xen should
+                  auto-switch input to DOM0 when it boots -- if it is 'x'
+                  then auto-switching is disabled. Any other value, or
+                  omitting the character, enables auto-switching.
+ [NB. Default for this option is 'a']
+
  dom0_mem=xxx    Set the initial amount of memory for domain0.
 
  pdb=xxx          Enable the pervasive debugger.  See docs/pdb.txt
index 0c64ecd409efa8db6b6e7b4c09da171d19eda846..b0ec801659a928468ec3b03903fe8ee8c8744fd1 100644 (file)
@@ -253,6 +253,16 @@ The following is a list of command line arguments to pass to Xen:
                   transmitted/received character.
  [NB. Default for this option is 'com1,tty']
 
+ conswitch=<switch-char><auto-switch-char>
+                  Specify how to switch serial-console input between
+                  Xen and DOM0. The required sequence is CTRL-<switch_char>
+                  pressed three times. Specifying '`' disables switching.
+                  The <auto-switch-char> specifies whether Xen should
+                  auto-switch input to DOM0 when it boots -- if it is 'x'
+                  then auto-switching is disabled. Any other value, or
+                  omitting the character, enables auto-switching.
+ [NB. Default for this option is 'a']
+
  dom0_mem=xxx     Set the maximum amount of memory for domain0.
 
  tbuf_size=xxx    Set the size of the per-cpu trace buffers, in pages
index a2fbd45dac2a6a98b8a21baad0bd85951d0986e6..b90d467f9e6eac2d52374d7b96723e73a3d56340 100644 (file)
@@ -40,6 +40,11 @@ void start_of_day(void);
 
 /* opt_console: comma-separated list of console outputs. */
 unsigned char opt_console[30] = "com1,vga";
+/* opt_conswitch: a character pair controlling console switching. */
+/* Char 1: CTRL+<char1> is used to switch console input between Xen and DOM0 */
+/* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
+/*         boots. Any other value, or omitting the char, enables auto-switch */
+unsigned char opt_conswitch[5] = "a"; /* NB. '`' would disable switching. */
 /* opt_com[12]: Config serial port with a string <baud>,DPS,<io-base>,<irq>. */
 unsigned char opt_com1[30] = "", opt_com2[30] = "";
 /* opt_dom0_mem: Kilobytes of memory allocated to domain 0. */
@@ -82,6 +87,7 @@ static struct {
     void *var;
 } opts[] = {
     { "console",           OPT_STR,  &opt_console },
+    { "conswitch",         OPT_STR,  &opt_conswitch },
     { "com1",              OPT_STR,  &opt_com1 },
     { "com2",              OPT_STR,  &opt_com2 },
     { "dom0_mem",          OPT_UINT, &opt_dom0_mem }, 
index 26362bdee0cd0571d0e2897ef99e753d95825ae3..b1887fa1fbb4585d143ba5e245c2748c006b80cf 100644 (file)
@@ -17,6 +17,8 @@
 #include <xen/keyhandler.h>
 #include <asm/uaccess.h>
 
+extern unsigned char opt_console[], opt_conswitch[];
+
 static int xpos, ypos;
 static unsigned char *video = __va(0xB8000);
 
@@ -227,17 +229,18 @@ long read_console_ring(unsigned long str, unsigned int count, unsigned cmd)
 static char serial_rx_ring[SERIAL_RX_SIZE];
 static unsigned int serial_rx_cons, serial_rx_prod;
 
-/* CTRL-a switches input direction between Xen and DOM0. */
-#define CTRL_A 0x01
+/* CTRL-<switch_char> switches input direction between Xen and DOM0. */
+#define SWITCH_CODE (opt_conswitch[0]-'a'+1)
 static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */
 
 static void switch_serial_input(void)
 {
     static char *input_str[2] = { "DOM0", "Xen" };
     xen_rx = !xen_rx;
-    printk("*** Serial input -> %s "
-           "(type 'CTRL-a' three times to switch input to %s).\n",
-           input_str[xen_rx], input_str[!xen_rx]);
+    if ( SWITCH_CODE != 0 )
+        printk("*** Serial input -> %s "
+               "(type 'CTRL-%c' three times to switch input to %s).\n",
+               input_str[xen_rx], opt_conswitch[0], input_str[!xen_rx]);
 }
 
 static void __serial_rx(unsigned char c, struct pt_regs *regs)
@@ -264,20 +267,20 @@ static void __serial_rx(unsigned char c, struct pt_regs *regs)
 
 static void serial_rx(unsigned char c, struct pt_regs *regs)
 {
-    static int ctrl_a_count = 0;
+    static int switch_code_count = 0;
 
-    if ( c == CTRL_A )
+    if ( (SWITCH_CODE != 0) && (c == SWITCH_CODE) )
     {
-        /* We eat CTRL-a in groups of three to switch console input. */
-        if ( ++ctrl_a_count == 3 )
+        /* We eat CTRL-<switch_char> in groups of 3 to switch console input. */
+        if ( ++switch_code_count == 3 )
         {
             switch_serial_input();
-            ctrl_a_count = 0;
+            switch_code_count = 0;
         }
     }
     else
     {
-        ctrl_a_count = 0;
+        switch_code_count = 0;
     }
 
     /* Finally process the just-received character. */
@@ -395,7 +398,6 @@ void set_printk_prefix(const char *prefix)
 
 void init_console(void)
 {
-    extern unsigned char opt_console[];
     unsigned char *p;
 
     /* Where should console output go? */
@@ -418,6 +420,15 @@ void console_endboot(int disable_vga)
 {
     if ( disable_vga )
         vgacon_enabled = 0;
+
+    /*
+     * If user specifies so, we fool the switch routine to redirect input
+     * straight back to Xen. I use this convoluted method so we still print
+     * a useful 'how to switch' message.
+     */
+    if ( opt_conswitch[1] == 'x' )
+        xen_rx = !xen_rx;
+
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();
 }